home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
c_lang
/
varinc.lzh
/
PAGE204A.C
< prev
next >
Wrap
Text File
|
1979-11-30
|
553b
|
14 lines
/* Count the number of lines and characters in stdin(). */
#include <stdio.h>
main()
{
int input; /* input returned from getchar() */
long chars, lines; /* counters for lines and characters */
for (lines = chars = 0; (input = getchar()) != EOF; ++chars)
if (input == '\n') /* End of a line? */
++lines; /* Yes. Increment count of lines. */
printf("%ld lines, %ld characters\n", lines, chars);
}